
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
const int N = 1010;
typedef pair<int, int> PII;
PII q[N * N];
char map[N][N];
int cnt, n;
bool st[N][N];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
void bfs(int x, int y, int &total, int &border)
{
    int hh = 0, tt = 0;
    q[0] = {x, y};
    st[x][y] = true;
    while (hh <= tt)
    {
        total++;
        bool is_border = false;
        PII temp = q[hh++];
        for (int i = 0; i < 4; i++)
        {
            int a = temp.first + dx[i], b = temp.second + dy[i];

            if (a >= 0 && a < n && b >= 0 && b < n && !st[a][b] && map[a][b] == '.')
            {
                is_border = true;
                continue;
            }
            else if (!st[a][b] && map[a][b] == '#')
            {
                q[++tt] = {a, b};
                st[a][b] = true;
            }
        }
        if (is_border)
            border++;
    }
}
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> map[i];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (!st[i][j] && map[i][j] == '#')
            {

                int total = 0, border = 0;
                bfs(i, j, total, border);
                if (total == border)
                    cnt++;
            }
    cout << cnt << endl;
    return 0;
}